import { setError } from './error'
import CryptoJS from 'crypto-js'
export const APPID = "wxd90371be5d857d17";
export const APPSERCET = "MgpZKz2Ly4hXXsJcIhfGJBuNlzw8Amun";
export const AESKEY = CryptoJS.enc.Utf8.parse('Tv1gyI4vUeWK0Bib') // 密匙
export const AESIV = CryptoJS.enc.Utf8.parse('2516325478965124') // 偏移量
export function handleError(response) {
  if (response && response.data && response.data.code === 0) {
    return true
  } else {
    const msg = response && response.data && response.data.msg
    if (msg) {
      showToast(msg)
    } else {
      setError('数据加载失败，请重试')
    }
    return false
  }
}

export function showToast(title, success = false) {
  success ? mpvue.showToast({ title })
    : mpvue.showToast({ title, icon: 'none' })
}
